//
//  YGUser.swift
//  sinaWeiBoGui
//
//  Created by liyonggui on 16/5/16.
//  Copyright © 2016年 liyonggui. All rights reserved.
//

import UIKit

class YGUser: NSObject {
    
    /// 用户UID
    var id: Int64 = 0
    /// 用户昵称
    var screen_name: String?
    /// 用户头像地址（中图），50×50像素
    var profile_image_url: String?
    
//    created_at	string	用户创建（注册）时间
    /// 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1 {
        didSet {
            switch verified_type {
            case 0:     verifiedImage = UIImage(named: "avatar_vip")
            case 2,3,4: verifiedImage = UIImage(named: "avatar_grassroot")
            case 220:   verifiedImage = UIImage(named: "avatar_enterprise_vip")
            default:    verifiedImage = nil
            }
        }
    }
    
    /// 模型提供认证图标
    var verifiedImage: UIImage?
    
    /// 会员等级1--6
    var mbrank: Int = 0 {
        didSet {
            // 1--6 级
            if mbrank > 0 && mbrank <= 6 {
                let imageName = "common_icon_membership_level\(mbrank)"
                mbrankImage = UIImage(named: imageName)
            } else {
                // 不是1--6级
                mbrankImage = nil
            }
        }
    }
    
    /// 模型提供会员等级图标
    var mbrankImage: UIImage?
    
    init(dic: [String: AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dic)
    }
    
    // 没有对应的属性会调用
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    // 打印本类的描述
    override var description:String {
        get {
            let keys = ["id", "screen_name", "profile_image_url", "verified_type", "mbrank"]
            return "\n \t \t用户模型： \(dictionaryWithValuesForKeys(keys))"
            
        }
    }
    

}
























